﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace ElingOA6_Admin_DSJCJ.BLL
{
    /// <summary>
    /// 相册 逻辑类
    /// </summary>
    public class Album
    {
        /// <summary>
        /// 相册
        /// </summary>
        private DAL.Album albumDAL = new DAL.Album();
        public Album()
        {
        }
        /// <summary>
        /// 获取当前目录下最大顺序号
        /// <create>wangl</create>
        /// <date>2014-10-13</date>
        /// </summary>
        /// <param name="albumClsNo"></param>
        /// <param name="entityNo"></param>
        /// <returns></returns>
        public int GetDirMaxSeq(string albumClsNo, string entityNo)
        {
            return albumDAL.GetDirMaxSeq(albumClsNo, entityNo);
        }
        /// <summary>
        /// 得到一个对象实体
        /// <create>wangl</create>
        /// <date>2014-10-13</date>
        /// </summary>
        public ElingOA6_Admin_DSJCJ.Model.Album GetModel(int albumId)
        {
            return albumDAL.GetModel(albumId);
        }
         /// <summary>
        /// 保存文件数据
        /// <create>wangl</create>
        /// <date>2014-10-13</date>
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int DocAdd(Model.Album model)
        {
            return albumDAL.DocAdd(model);
        }
         /// <summary>
        /// 更新文件数据
        /// <create>wangl</create>
        /// <date>2014-10-13</date>
        /// </summary>
        /// <param name="model"></param>
        /// <param name="oldSeq"></param>
        public void UpdateDoc(Model.Album model, int oldSeq)
        {
            albumDAL.UpdateDoc(model, oldSeq);
        }
         /// <summary>
        /// 获取二进制
        /// <create>rend</create>
        /// <date>2012-12-4</date>
        /// </summary>
        /// <param name="docId"></param>
        /// <returns></returns>
        public byte[] GetContentBin(int albumId)
        {
            return albumDAL.GetContentBin(albumId);
        }
        /// <summary>
        /// 删除一条数据
        /// <create>wangl</create>
        /// <date>2014-10-13</date>
        /// </summary>
        public void Delete(int albumId)
        {
            albumDAL.Delete(albumId);
        }
        /// <summary>
        /// 获取背景音乐地址和图片播放间隔
        /// <creator>wangl</creator>
        /// <date>2014-10-14</date>
        /// </summary>
        /// <param name="FDocId"></param>
        /// <returns></returns>
        public List<string> GetBGMusicPathAndPlayInterval(int FDocId)
        {
            List<string> list = new List<string>();

            DataSet ds = albumDAL.GetBGMusicPathAndPlayInterval(FDocId);
            if (ds.Tables[0].Rows.Count > 0)
            {
                list.Add(ds.Tables[0].Rows[0]["FBGMusicPath"].ToString());
                list.Add(ds.Tables[0].Rows[0]["FPlayInterval"].ToString());
            }

            return list;
        }
        /// <summary>
        /// 获得数据列表
        /// <create>wangl</create>
        /// <date>2014-10-13</date>
        /// </summary>
        public List<ElingOA6_Admin_DSJCJ.Model.Album> DataTableToList(DataTable dt)
        {
            List<ElingOA6_Admin_DSJCJ.Model.Album> modelList = new List<ElingOA6_Admin_DSJCJ.Model.Album>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                ElingOA6_Admin_DSJCJ.Model.Album model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = albumDAL.DataRowToModel(dt.Rows[n]);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }
    }
}
